package com.android.dongshouzhi.fragment.member;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.TextView;

import com.android.dongshouzhi.R;
import com.android.dongshouzhi.fragment.BaseLazyFragment;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * 常见问题
 */
public class Fragment_Mine_CommonProblem extends BaseLazyFragment {

    @BindView(R.id.problem_wb)
    WebView wb;
    @BindView(R.id.problem_title)
    TextView title;
    private FragmentActivity mcontext;
    private View view;
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    private String mTitle;
    private String mContent;

    public Fragment_Mine_CommonProblem() {

    }

    public static Fragment_Mine_CommonProblem newInstance(String title, String content) {
        Fragment_Mine_CommonProblem fragment = new Fragment_Mine_CommonProblem();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, title);
        args.putString(ARG_PARAM2, content);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mTitle = getArguments().getString(ARG_PARAM1);
            mContent = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    protected void initPrepare() {
    }


    @Override
    protected void onInvisible() {
    }

    @Override
    protected void initData() {
        title.setText(mTitle);
        String js = "<style>\n" +
                "img{\n" +
                " max-width:100%;\n" +
                "height:auto\n" +
                "}\n" +
                "</style>" + mContent;

        wb.loadDataWithBaseURL(null, js, "text/html", "utf-8", null);
    }

    @Override
    protected View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_mine_commonproblem, container, false);
        mcontext = getActivity();
        ButterKnife.bind(this, view);
        return view;
    }
}
